/* 
 * File:   unlink.c
 * Author: matheus
 *
 * Created on May 3, 2011, 7:01 PM
 */
#include <sys/types.h>
#include <sys/ipc.h>
#include <sys/shm.h>
#include <stdio.h>
#include <errno.h>
#include <stdlib.h>
#include <fcntl.h>           /* For O_* constants */
#include <sys/stat.h>        /* For mode constants */
#include <semaphore.h>
#include <unistd.h>
#include <pthread.h>
#include "indices.h"
#include "others.h"

int main(int argc, char** argv) {
    sem_unlink(MUTEX_SEM);
    sem_unlink(BOARD_MUTEX_SEM);
    sem_unlink(MS_SEM);
    sem_unlink(HL_SEM);

    char * sharedMem;

    int shMemSegID;

    int shmFlags = 0;

    if ((shMemSegID = shmget(SHM_KEY, 7 * sizeof (char), shmFlags)) < 0) {
        exit(EXIT_FAILURE);
    }

    shmFlags = 0;
    if ((sharedMem = shmat(shMemSegID, NULL, shmFlags)) == (void *) - 1) {
        exit(EXIT_FAILURE);
    }

    if (shmdt(sharedMem) < 0) {
        exit(EXIT_FAILURE);
    }

    if (shmctl(shMemSegID, IPC_RMID, NULL) < 0) {
        exit(EXIT_FAILURE);
    }
    return (EXIT_SUCCESS);
}

